#ifndef __INDEX_BENCHE__
#define __INDEX_BENCHE__
#include "uvpacket.h"
#include "packetparser.h"
#include "threadpool.h"
#include "socket.h"
#include "uvlog.h"

using namespace std;




#define SAFE_ERROR_LOG(fmt,args...)  do{\
							pthread_mutex_lock(&mutex);\
							LOG_ERROR(fmt, ##args);\
							pthread_mutex_unlock(&mutex);\
						}while(0);



class CTestTool: public ThreadPool
{
	public:
		CTestTool(string ip,int p);
		~CTestTool(){}

		void process(int count);
		int getState() { return insert_done;}
		uint64_t getTastCount() {return index;};

	protected:
		virtual bool RunOnce();
		virtual void StopThreads(size_t stopcount);
		bool testInsertIndex(Socket *s, uint64_t index);
		bool testDeleteIndex(Socket *s, uint64_t index);
		bool testQueryIndex(Socket *s, uint64_t index);

	private:
		volatile int insert_done;
		volatile uint64_t index;
		UVPacket parser;
		string addr;
		int port;
		
};
#endif

